package submarines;

import submarines.notices.NoticePlayerQuit;
import submarines.notices.Notice;

/**
 *
 * @author elad + shiran
 * 
 * This class is actually the one that activates each turn
 */
public class TurnManager {
    protected boolean lastTurnHit;

    /*
     * Enum to hold the different turn action options.
     * the toString override is used in printing the menu
     */
    static public enum turnAction {
       MARK_ON_ENEMY_BOARD,
       UNMARK_ON_ENEMY_BOARD,
       SEND_TORPEDO,
       VIEW_ENEMY_BOARD,
       QUIT_GAME;
       
        @Override
        public String toString() {
            String s;
            switch(this) {
                case MARK_ON_ENEMY_BOARD: s = "Mark square on an enemy board"; break;
                case SEND_TORPEDO: s = "Send a torpedo on enemy"; break;
                case UNMARK_ON_ENEMY_BOARD: s = "Unark square on an enemy board"; break;
                case QUIT_GAME: s = "Quit the game"; break;
                case VIEW_ENEMY_BOARD: s = "View enemy's board"; break;
                default: s= "Invalid option";
            }
            return s;
        };
    }    
    
    public TurnManager() {
    }
        
    void playTurn() {
        Player thisTurn;
        thisTurn = Main.pManager.getNextPlayer();
        if (thisTurn.playTurn()) {
            NoticePlayerQuit q = new NoticePlayerQuit(thisTurn, Notice.NoticeType.PLAYER_QUIT);
            Main.nManager.spreadTheWord(thisTurn, thisTurn, q);
            Main.pManager.playerQuit(thisTurn);
        }
    }
}
